package cn.org.guhao.practice.go.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Department implements Serializable {

  private Integer id;

  private Integer parentId;

  private String name;

  private transient List<Department> subDepartments;

  private transient Department parent;

  public Department(Integer id, String name) {
    this.id = id;
    this.name = name;
  }

  public Department(Integer id, Integer parentId, String name) {
    this.id = id;
    this.parentId = parentId;
    this.name = name;
  }

  public Integer getId() {
    return id;
  }

  public void setId(Integer id) {
    this.id = id;
  }

  public Integer getParentId() {
    return parentId;
  }

  public void setParentId(Integer parentId) {
    this.parentId = parentId;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public List<Department> getSubDepartments() {
    return subDepartments;
  }

  public void setSubDepartments(List<Department> subDepartments) {
    this.subDepartments = subDepartments;
  }

  public Department getParent() {
    return parent;
  }

  public void setParent(Department parent) {
    this.parent = parent;
  }

  public List<Department> add(Department department){
    if (subDepartments == null){
      subDepartments = new ArrayList<Department>();
    }
    subDepartments.add(department);
    return subDepartments;
  }

}
